/*
 * @(#)CharmBoardGroup.java $version 2013. 7. 10.
 *
 */

package com.pace.gonu.constants;

import java.util.ArrayList;
import java.util.List;

/**
 * @author pace
 */
public enum CharmBoardGroup {
	/* 가로*/
	g1(CharmBoardXY.r1, CharmBoardXY.r2, CharmBoardXY.r3), 
	g2(CharmBoardXY.r4, CharmBoardXY.r5, CharmBoardXY.r6), 
	g3(CharmBoardXY.r7, CharmBoardXY.r8, CharmBoardXY.r9),
	g4(CharmBoardXY.r10, CharmBoardXY.r11, CharmBoardXY.r12), 
	g5(CharmBoardXY.r13, CharmBoardXY.r14, CharmBoardXY.r15), 
	g6(CharmBoardXY.r16, CharmBoardXY.r17, CharmBoardXY.r18),
	g7(CharmBoardXY.r19, CharmBoardXY.r20, CharmBoardXY.r21),
	g8(CharmBoardXY.r22, CharmBoardXY.r23, CharmBoardXY.r24),
	/*세로*/
	g9(CharmBoardXY.r1, CharmBoardXY.r10, CharmBoardXY.r22),
	g10(CharmBoardXY.r4, CharmBoardXY.r11, CharmBoardXY.r19),
	g11(CharmBoardXY.r7, CharmBoardXY.r12, CharmBoardXY.r16),
	g12(CharmBoardXY.r2, CharmBoardXY.r5, CharmBoardXY.r8),
	g13(CharmBoardXY.r17, CharmBoardXY.r20, CharmBoardXY.r23),
	g14(CharmBoardXY.r9, CharmBoardXY.r13, CharmBoardXY.r18),
	g15(CharmBoardXY.r6, CharmBoardXY.r14, CharmBoardXY.r21),
	g16(CharmBoardXY.r3, CharmBoardXY.r15, CharmBoardXY.r24),
	/*사선*/
	g17(CharmBoardXY.r1, CharmBoardXY.r4, CharmBoardXY.r7),
	g18(CharmBoardXY.r3, CharmBoardXY.r6, CharmBoardXY.r9),
	g19(CharmBoardXY.r22, CharmBoardXY.r19, CharmBoardXY.r16),
	g20(CharmBoardXY.r24, CharmBoardXY.r21, CharmBoardXY.r18);

	private CharmBoardXY one;
	private CharmBoardXY two;
	private CharmBoardXY three;

	CharmBoardGroup(CharmBoardXY one, CharmBoardXY two, CharmBoardXY three) {
		this.one = one;
		this.two = two;
		this.three = three;
	}

	public static List<CharmBoardGroup> getIncludeGroup(int x, int y) {
		List<CharmBoardGroup> charmBoardGroups = new ArrayList<CharmBoardGroup>();
		for (CharmBoardGroup charmBoardGroup : CharmBoardGroup.values()) {
			if (charmBoardGroup.getOne().getX() == x &&  charmBoardGroup.getOne().getY() == y) {
				charmBoardGroups.add(charmBoardGroup);
			} else if (charmBoardGroup.getTwo().getX() == x && charmBoardGroup.getTwo().getY() == y) {
				charmBoardGroups.add(charmBoardGroup);
			} else if (charmBoardGroup.getThree().getX() == x && charmBoardGroup.getThree().getY() == y) {
				charmBoardGroups.add(charmBoardGroup);
			}
		}
		return charmBoardGroups;
	}

	public List<CharmBoardXY> getListValues() {
		List<CharmBoardXY> charmBoardXYList = new ArrayList<CharmBoardXY>();
		charmBoardXYList.add(this.one);
		charmBoardXYList.add(this.two);
		charmBoardXYList.add(this.three);
		return charmBoardXYList;
	}

	public CharmBoardXY getOne() {
		return one;
	}

	public CharmBoardXY getTwo() {
		return two;
	}

	public CharmBoardXY getThree() {
		return three;
	}

}
